package com.framework.auth.controller;

import com.framework.auth.service.AuthService;
import com.framework.common.request.CustomInfoReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

/**
 * @author zhoubb
 * @version V1.0
 * @Date 2020/4/12 17:42
 * @since JDK 1.8
 */
@RestController
@RequestMapping("user")
@Api(value = "UserController", description = "获取授权用户")
public class UserController {

    @Autowired
    AuthService authService;

    /**
     * 获取授权的用户信息
     * @param principal 当前用户
     * @return 授权信息
     */
    @ApiOperation(value = "获取授权的用户信息", httpMethod = "GET")
    @GetMapping("current/get")
    public Principal user(@ApiParam(name="principal",value="用户信息",required=true) Principal principal){
        return principal;
    }


    @RequestMapping(value = "/refreshTtzAuthentication",method = RequestMethod.POST)
    public void refreshTtzAuthentication(@RequestBody CustomInfoReq customInfoReq) {
        authService.refreshTtzAuthentication(customInfoReq);
    }
}
